{% extends 'base.html' %}
{% block content %}
<div class="container mt-3">
  <h3>软件许可</h3>
  <form method="get" class="mb-3 d-flex" role="search">
    <input class="form-control me-2" type="search" placeholder="搜索软件名/密钥" name="q" value="{{ query|default:'' }}">
    <button class="btn btn-primary" type="submit">搜索</button>
    <a class="btn btn-success ms-2" href="{% url 'assets:license_create' %}">新增许可</a>
  </form>
  <table class="table table-striped">
    <thead>
      <tr>
        <th>软件</th>
        <th>许可密钥</th>
        <th>数量</th>
        <th>有效期</th>
        <th>状态</th>
      </tr>
    </thead>
    <tbody>
      {% for l in page_obj %}
      <tr>
        <td>{{ l.software.name }}</td>
        <td><a href="{% url 'assets:license_detail' l.id %}">{{ l.license_key|default:'(无)' }}</a></td>
        <td>{{ l.seats }}</td>
        <td>{{ l.start_date }} ~ {{ l.end_date }}</td>
        <td>{{ l.get_status_display }}</td>
      </tr>
      {% empty %}
      <tr><td colspan="5" class="text-center">无数据</td></tr>
      {% endfor %}
    </tbody>
  </table>
  {% include 'assets/_pagination.html' with page_obj=page_obj %}
</div>
{% endblock %}
